﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ControlIP.DataTypes.DomainObjects;
using Raven.Client.Document;
using Hardcodet.Wpf.TaskbarNotification;
using rv= RavenAcessLayer;
namespace ControlIPApp
{

    public class ShowMessageCommand : ICommand
    {
        public void Execute(object parameter)
        {
            MessageBox.Show(parameter.ToString());
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;
    } 

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private TaskbarIcon tb;

        private void initIcon() 
        {
            tb = new TaskbarIcon();
            tb.ToolTipText = "Bi4all - Report";
            String path = System.AppDomain.CurrentDomain.BaseDirectory + "\\Images\\1352761121_chart_pie.ico";

            tb.Icon = new System.Drawing.Icon(path);
            tb.PopupActivation = PopupActivationMode.LeftClick;



        }


        public void SaveCommand(object sender, ContextMenuEventArgs e)
        {
            int a = 2;
            a += 34;
        }

        public MainWindow()
        {
            InitializeComponent();

            lbName.Content = ControlIpCommom.Global.GlobalCache.User.Name;
            lbUserName.Content = ControlIpCommom.Global.GlobalCache.User.Username;

            tb = (TaskbarIcon)FindResource("MyNotifyIcon");
            String path = System.AppDomain.CurrentDomain.BaseDirectory + "\\Images\\1352761121_chart_pie.ico";

            tb.Icon = new System.Drawing.Icon(path);
            //initIcon();
        }

        private void commandButton1_Click(object sender, RoutedEventArgs e)
        {

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
           
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {

          


        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {

            using (var db = rv.DataContext.Db.Session )
            {

                //Create a New Thing
                var thing3 = new Employee()
                {
                    Name = "Thing 3",
                 
                };

                thing3.Save();
            }


        }

        private void Label_MouseDoubleClick_1(object sender, MouseButtonEventArgs e)
        {
        }

        private void Label_MouseDown_1(object sender, MouseButtonEventArgs e)
        {
            if( e.LeftButton == MouseButtonState.Pressed )
            {

                ucConsultRegisters consult = new ucConsultRegisters();
                consult.Height = double.NaN;
                consult.Width = double.NaN;

                consult.Margin = new Thickness(0);
                consult.VerticalAlignment = VerticalAlignment.Stretch;
                consult.HorizontalAlignment = HorizontalAlignment.Stretch;


                if (dockPanel1.Children.Count > 0)
                    dockPanel1.Children.RemoveAt(0);

                dockPanel1.Children.Add(consult);

            }
        }

        private void lbAdd_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                ucAddRegister consult = new ucAddRegister();
                consult.Height = double.NaN;
                consult.Width = double.NaN;

                consult.Margin = new Thickness(0);
                consult.VerticalAlignment = VerticalAlignment.Stretch;
                consult.HorizontalAlignment = HorizontalAlignment.Stretch;


                if (dockPanel1.Children.Count > 0)
                    dockPanel1.Children.RemoveAt(0);

                dockPanel1.Children.Add(consult);
            }
        }
    }
}
